const path = require('path')
const nodeExten = require("webpack-node-externals")
const { merge } = require('webpack-merge')
const baseConfig = require('./webpack.base')


module.exports = merge(baseConfig, {
    entry: {
        main: './src/app.js'
    },
    output: {
        filename: 'server.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: "/"
    },
    target: 'node',
    externals: [nodeExten()],
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    "isomorphic-style-loader",
                    {
                        loader: 'css-loader',
                        options: {
                            modules: true,
                            esModule: false,
                        }
                    }
                ]
            },
            {
                test: /\.(png|jpg|gif|jpeg)$/,
                use: [{
                    loader: 'file-loader',
                    options: {
                        name: "img/[name].[hash:5].[ext]",
                        limit: 10 * 1024,
                        emitFile: false // 不生成文件
                    }
                }],
                type: 'javascript/auto'
            }
        ]
    }
})